# -*- coding: utf-8 -*-
from openerp.osv import osv
from openerp.tools.translate import _


class ir_filters(osv.osv):
    _inherit='ir.filters'

    def unlink(self,cr,uid,ids,context=None):
        for filter in self.browse(cr,uid,ids,context=context):
            user=self.pool.get('res.users').browse(cr,uid,uid,context=context)
            if not filter.user_id and not self.pool.get('res.users').has_group(cr,uid,'base.group_erp_manager'):
                raise osv.except_osv(_('Warning!'),
                                     u'全局的过滤器不允许删除！')
        return super(ir_filters,self).unlink(cr,uid,ids,context=context)